package com.vancouver.knows.manager;

import com.pangu.MobBeanManager;
import com.vancouver.knows.MainApplication;
import com.vancouver.knows.PhoContextConfig;

/**
 * Play的Bean管理器
 * <p/>
 * Created by cxlin
 */
public class PhoBeanManager extends MobBeanManager {

    private MainApplication imContext;

    public PhoBeanManager(MainApplication imContext) {
        super(imContext);

        this.imContext = imContext;
    }

    @Override
    protected <T> T createBean(Class<T> clazz, String mark) {
        Object obj = null;
        if (clazz == PhoSharedPrefManager.class) {
            obj = new PhoSharedPrefManager(imContext);

        } else if (clazz == PhoContextConfig.class) {
            obj = new PhoContextConfig();

        } else {
            obj = super.createBean(clazz, mark);
        }

        return (T) obj;
    }

    /**
     * 获取配置文件
     *
     * @return
     */
    public PhoSharedPrefManager getSharedPrefManager() {
        return getBean(PhoSharedPrefManager.class);
    }


    /**
     * 获取环境配置
     *
     * @return
     */
    public PhoContextConfig getContextConfig() {
        return getBean(PhoContextConfig.class);
    }

}
